﻿using System;
using System.Linq;
using Framework.Poco;
using Shell.DomainDot;
using System.Collections.Generic;

namespace Framework.Domain
{
    /// <summary>
    /// 文章选择器
    /// </summary>
    public class SelectArticle : DomainDotBase
    {
        /// <summary>
        /// 所有的文章
        /// </summary>
        public WithAll<Article> Articles { private get; set; }

        /// <summary>
        /// 与分类相关的所有文章
        /// </summary>
        public WithAll<ArticleByCategoryPairSelector, Article> ArticleByCategory { get; set; }

        /// <summary>
        /// 获取所有文章
        /// </summary>
        public IEnumerable<Article> GetAllArticle()
        {
            return this.Articles;
        }

        /// <summary>
        /// 获取指定Id的文章
        /// </summary>
        public Article Select(Guid identity)
        {
            return this.Articles.SingleOrDefault(i => i.Id.Equals(identity));
        }
    }
}
